
package GUI;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import javax.swing.*;

/**
 * @author Hern&aacute;ndez Abahonza Diana Carolina 1031083
 * @author L&oacute;pez Juan Camilo
 * @author Moncada Mu&nacute;oz Juan David
 */
public class PanelMediosPago extends JPanel implements ActionListener {
    
    private JLabel lMediosPago;
    private ArrayList<JLabel> lDatosMedPago;
    private ArrayList<JLabel> lDatosTarjeta;
    private ArrayList<JTextField> tfDatosMedPago;
    private ArrayList<JTextField> tfDatosTarjeta;
    private JButton bCrear;
    private JButton bModificar;
    private JButton bEliminar;
    
    public PanelMediosPago(){
        this.setLayout(new BorderLayout(5,0));//ec, ef
	
	inicializarComponentes();
	organizarComponentes();
    }
    
    // Métodos privados
    
    private void inicializarComponentes() {
        lMediosPago = new JLabel("Gestión Medios de Pago", new ImageIcon("images/graphique-money-24x24.png"), SwingConstants.LEFT);
	lMediosPago.setFont(new Font("Arial", Font.BOLD, 18));
	lMediosPago.setForeground(new Color(78,79,99,190));
        
        lDatosMedPago = new ArrayList<JLabel>();
        lDatosMedPago.add( new JLabel( "Tipo de Medio de Pago" ) );
        lDatosMedPago.add( new JLabel( "Número Máximo de Cuotas" ) );
        
        lDatosTarjeta = new ArrayList<JLabel>();
        lDatosTarjeta.add( new JLabel( "Número Tarjeta" ) );
        lDatosTarjeta.add( new JLabel( "Número de Aprobación" ) );
        lDatosTarjeta.add( new JLabel( "Franquicia" ) );
        lDatosTarjeta.add( new JLabel( "Banco" ) );
        
        tfDatosMedPago = new ArrayList<JTextField>();
        
        for(int i=0; i<lDatosMedPago.size(); i++){
            lDatosMedPago.get(i).setFont(new Font("Arial", Font.BOLD, 14));
            lDatosMedPago.get(i).setForeground(new Color(78,79,99,190));
            
            tfDatosMedPago.add( new JTextField( "" ) );
	}
        
        tfDatosTarjeta = new ArrayList<JTextField>();
        
        for(int i=0; i<lDatosTarjeta.size(); i++){
            lDatosTarjeta.get(i).setFont(new Font("Arial", Font.BOLD, 14));
            lDatosTarjeta.get(i).setForeground(new Color(78,79,99,190));
            
            tfDatosTarjeta.add( new JTextField( "" ) );
	}
        
        bCrear = new JButton("Crear");
        configurarBoton(bCrear);
        
        bModificar = new JButton("Modificar");
        configurarBoton(bModificar);
        
        bEliminar = new JButton("Eliminar");
        configurarBoton(bEliminar);
    }
    
    private void configurarBoton(JButton boton){
        boton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
	boton.setRolloverEnabled(false); // Quita la iluminacion al pasar el mouse por el boton 
	//boton.setBorderPainted(false); // Quita el borde del boton
	boton.setBackground(new Color(0,0,0,0)); // Fondo Transparente
	boton.addActionListener(this); // Escucha del boton
    }

    private void organizarComponentes() {
        // parte Norte
        JPanel pTitulo = new JPanel();
	pTitulo.setBorder(BorderFactory.createEmptyBorder(80,110,25,110));//n,w,s,e
	pTitulo.setBackground(new Color(0,0,0,0));
	pTitulo.add(lMediosPago);
	
        // parte Centro
	JPanel pMedPago = new JPanel(new GridLayout(lDatosMedPago.size(),2,0,2));//i,j,esp_i, esp_j
	pMedPago.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(20,30,60,30), "Datos Generales"));//n,w,s,e
	pMedPago.setBackground(new Color(0,0,0,0));
	for(int i=0; i<lDatosMedPago.size(); i++){
            pMedPago.add(lDatosMedPago.get(i));
            pMedPago.add(tfDatosMedPago.get(i));
	}
        
        JPanel pDatTarj = new JPanel(new GridLayout(lDatosTarjeta.size(),2,0,2));//i,j,esp_i, esp_j
	pDatTarj.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(20,30,0,30), "Datos Tarjeta"));//n,w,s,e
	pDatTarj.setBackground(new Color(0,0,0,0));
	for(int i=0; i<lDatosTarjeta.size(); i++){
            pDatTarj.add(lDatosTarjeta.get(i));
            pDatTarj.add(tfDatosTarjeta.get(i));
	}
        
        JPanel pCentral = new JPanel(new GridLayout(2,1,0,0));
        pCentral.setBorder(BorderFactory.createEmptyBorder(25,110,25,110));//n,w,s,e
	pCentral.setBackground(new Color(0,0,0,0));
        pCentral.add(pMedPago);
        pCentral.add(pDatTarj);
        
        // parte Sur        
        JPanel pBotones = new JPanel(new GridLayout(1,3,5,0));
	pBotones.setBorder(BorderFactory.createEmptyBorder(25,110,100,110));//n,w,s,e
	pBotones.setBackground(new Color(0,0,0,0));
	pBotones.add(bCrear);
	pBotones.add(bModificar);
	pBotones.add(bEliminar);
        
        // general
	this.add(pTitulo, BorderLayout.NORTH);
	this.add(pCentral, BorderLayout.CENTER);
	this.add(pBotones, BorderLayout.SOUTH);
    }
    
    // ActionListener

    @Override
    public void actionPerformed(ActionEvent ae) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }    
}
